﻿namespace Leetcode.N0806;

public class Solution
{
    public int[] NumberOfLines(int[] widths, string s)
    {
        var lineWidth = 0;
        var rowsCount = 1;
        foreach (var item in s)
        {
            if (lineWidth + widths[item - 'a'] > 100)
            {
                rowsCount++;
                lineWidth = 0;
            }
            lineWidth += widths[item - 'a'];
        }

        return new int[] { rowsCount, lineWidth };
    }
}
